package lhdmn;
public class FoodOrderSystem {
    public static void main(String[] args) {
        // 1. 创建菜品
        MainDish rice = new MainDish("蛋炒饭", 15.0, 10, true, "米饭");
        Drink cola = new Drink("可乐", 5.0, 5, true, true);
        Drink milk = new Drink("牛奶", 6.0, 0, true, false); // 库存为0
        MainDish noodles = new MainDish("牛肉面", 25.0, 8, false, "面食"); // 已下架

        // 2. 创建顾客
        Customer customer = new Customer("张三", "13800138000");

        // 3. 创建订单并点餐
        Order order = new Order(customer, "ORD20251111001");
        try {
            order.addDish(rice);
            order.addDish(cola);
            System.out.println("点餐成功！");
            System.out.println("订单总价：" + order.calculateTotal());

            // 测试库存不足异常
            System.out.println("尝试点库存不足的牛奶：");
            order.addDish(milk);
        } catch (Exception e) {
            System.out.println("点餐异常：" + e.getMessage());
        }

        try {
            // 测试菜品下架异常
            System.out.println("尝试点已下架的牛肉面：");
            order.addDish(noodles);
        } catch (Exception e) {
            System.out.println("点餐异常：" + e.getMessage());
        }
    }
}